# TODO: Add comment
# 
# Author: forever
###############################################################################

library(png)
library(raster)

ras_file = "C:/a.tif"
pm = raster(ras_file)
pm_value = values(pm)
KML(pm,filename="C:/a.png",overwrite=TRUE)

totalCell=length(pm)
new_pm_value = 0 - pm_value
new_pm = pm
new_pm[1:totalCell]=new_pm_value
max(pm_value,na.rm = TRUE)
min(pm_value,na.rm = TRUE)
mean(pm_value,na.rm = TRUE)

KML(new_pm,filename="C:/a_new.png",maxpixels = 16400,overwrite=TRUE)